package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.query.album.TrackInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumTrackListVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TrackInfoMapper extends BaseMapper<TrackInfo> {


    Page<TrackListVo> getUserTrackPage(Page<TrackListVo> trackInfoVoPage, @Param("vo") TrackInfoQuery trackInfoQuery);

    Page<AlbumTrackListVo> selectTrackByAlbumId(Long albumId, Page<AlbumTrackListVo> trackListPage);

    @Update("update track_stat\n" +
            "set stat_num = stat_num + #{count},\n" +
            "    update_time = now()\n" +
            "where track_id = #{trackId}\n" +
            "  and stat_type = #{statType}\n" +
            "  and is_deleted = 0\n")
    void updateTrackStat(@Param("trackId") Long trackId, @Param("count") Integer count,@Param("statType") String statType);
}
